<?php
    echo Modules::run('ndh/header');
?>
<div class="clear" style="padding-bottom: 5px;"></div>   
        <div id="mainContent" style="width: 987px;">
            <table width="987" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                <tr valign="top">
                    <td>
                        <div id="leftContent" style="background-color: #FFFFFF;">
                <!-- news section -->
                <div id="newsSection">
                    <div id="news1">
                        <div id="banner-fade" style="width: 100%;">
                            <!-- start Basic Jquery Slider -->
                            <ul class="bjqs">
                            <?php
                                if(isset($market_news))
                                {
                                    foreach($market_news as $news)
                                    {
                                        $src = isset($news['upload']) ? base_url('uploads/company/report/'.$news['upload']) : base_url('uploads/company/report/finance1.jpg');
                            ?>
                              <li><a href="<?php echo site_url('ndh/nhandinhthitruong/'.$news['id']); ?>"><img src="<?php echo $src; ?>" title="<a href='<?php echo site_url('ndh/nhandinhthitruong/'.$news['id']); ?>' class='normalNews'><?php echo $news['title'];?></a>"></a></li>
                            <?php
                                    }
                                }
                            ?>
                            </ul>
                            <!-- end Basic jQuery Slider -->
                        <script class="secret-source">
                            jQuery(document).ready(function($) {

                              $('#banner-fade').bjqs({
                                height      : 202,
                                width       : 316,
                                responsive  : true,
                                showcontrols : false,            
                              });
                            });
                      </script>                        
                      </div>
                    </div>
                    <div id="news2">
                        <!-- tin moi nhat -->
                        <h1>tin mới nhất</h1>              
                        <div style=" border: 1px solid #CCCCCC; background-color: #FFFFFF;">                            
                            <?php
                                foreach($top_news as $new)
                                {
                            ?>
                            <p><img src="<?php echo base_url('images/bullet.jpg') ?>" alt="" /><a href="<?php echo site_url('ndh/news/index/'.$new['id']) ?>" class="normalNews"> <?php echo $new['title'] ?></a></p>                    
                            <?php
                                }
                                
                                $count_report = count($analyze_reports);
                            ?>
                        </div>
                        <!-- tin moi nhat -->
                        <br/>
                    </div>
                </div>
                <!-- news section -->
                <!-- security market -->
                <div id="securityMarket">
                    <table id="market" border="1" width="100%" style="background-color: #FFFFFF;">
                        <tr style="height: 24px;" align="center">
                            <th>DMĐT</th><th>VĐL (TỈ ĐỒNG)</th><th>EPS</th><th>DPS (CỔ TỨC)</th><th>BV</th><th>ROE (%)</th><th>% TĂNG DT</th><th>% TĂNG LN</th><th>HỆ SỐ NỢ</th><th>GIÁ</th><th>KHUYẾN NGHỊ</th>
                        </tr>
                        
                        <?php 
                            $i = 1;
                            foreach($stock_table as $stock)
                            {
                                $style = 'alt2';
                                if( $i % 2 == 0 )
                                {
                                    $style = 'alt1';
                                }     
                        ?>
                        <tr>
                            <td class="<?php echo $style; ?>"><a href="<?php echo site_url('ndh/news/company/'.$stock['company_id']) ?>" class="marketNews"><?php echo $stock['shortname']; ?></a></td>
                            <td class="<?php echo $style; ?>"><?php echo $stock['vdl']; ?></td>
                            <td class="<?php echo $style; ?>"><?php echo $stock['eps']; ?></td>
                            <td class="<?php echo $style; ?>"><?php echo $stock['dps']; ?></td>
                            <td class="<?php echo $style; ?>"><?php echo $stock['bv']; ?></td>
                            <td class="<?php echo $style; ?>"><?php echo $stock['roe']; ?></td>
                            <td class="<?php echo $style; ?>"><?php echo $stock['dtratio']; ?></td>
                            <td class="<?php echo $style; ?>"><?php echo $stock['lnratio']; ?></td>
                            <td class="<?php echo $style; ?>"><?php echo $stock['debt']; ?></td>
                            <td class="<?php echo $style; ?>"><?php echo $stock['price']; ?></td>
                            <td class="<?php echo $style; ?>"><?php echo $stock['suggest']; ?></td>
                        </tr>
                        <?php
                                $i++;
                            }
                        ?>
                    </table>
                </div>
                <!-- security market -->
            </div>              
                    </td>
                    <td><div id="rightContent" style="height: auto;">
                <!-- index table -->
                <div id="indextbl">Index</div>
                <div id="indexcontent" style="background-color: #FFFFFF;" class="halfmoon">
                <?php 
                require_once "simple_html_dom.php";
                $url = "http://www.bloomberg.com/";
                $html = file_get_html($url);

                $us = $html->find('div[id=market_snap_us]',0)->outertext;
                $europe = $html->find('div[id=market_snap_europe]',0)->outertext;
                $asia = $html->find('div[id=market_snap_asia]',0)->outertext;  
                ?>
                    <ul>
                        <li><a id="US" href="#">Mỹ</a></li>
                        <li><a id="Europe" href="#">Châu Âu</a></li>
                        <li><a id="Asia" href="#">Châu Á</a></li>
                    </ul>
                    <br/>
                    <div id="indexUS">
                       <?php echo str_replace('/quote/','http://www.bloomberg.com/quote/',$us); ?> 
                    </div>
                    <div id="indexEurope" style="display: none;"> 
                       <?php echo str_replace('/quote/','http://www.bloomberg.com/quote/',$europe); ?>
                    </div>
                    <div id="indexAsia" style="display: none;">
                       <?php echo str_replace('/quote/','http://www.bloomberg.com/quote/',$asia); ?>
                    </div>
                    <script>          
                       $("#US").click(function() {
                          $('#indexUS').show('slow');
                          $('#indexEurope').hide();
                          $('#indexAsia').hide();
                        });
                         
                       $("#Europe").click(function() {
                          $('#indexEurope').show('slow');
                          $('#indexUS').hide();
                          $('#indexAsia').hide();
                        });

                       $("#Asia").click(function() {
                          $('#indexAsia').show('slow');
                          $('#indexEurope').hide();
                          $('#indexUS').hide();
                        });
                    </script>
                    <br/>
                </div>
                <!-- index table -->
                
                <br/>
                <!-- nha dau tu -->
                <div id="indextbl">Nhà đầu tư</div>  
                <div id="indexcontent" style="background-color: #FFFFFF;" class="halfmoon">
                <table id="nhadautu" border="1" width="100%" style="background-color: #FFFFFF;">
                    <tr style="height: 24px;" align="center">
                        <td colspan="3" width="50%" style="border-right: 1px solid #CCCCCC;">NDT NƯỚC NGOÀI</td>
                        <td colspan="3" width="50%">NDT TRONG NƯỚC</td>
                    </tr>
                    <tr style="height: 24px;" align="center">
                        <th>&nbsp;</th>
                        <th>Mua</th>
                        <th>Bán</th>
                        <th>&nbsp;</th>
                        <th>Mua</th>
                        <th>Bán</th>
                    </tr>                    
                    <tr>
                    <?php
                    $foreign = array();
                    foreach( $investor_foreign as $investor )
                    {    
                        $foreign[] = $investor;
                    }

                    $inside = array();
                    foreach( $investor_data as $investor )
                    {
                                        $inside[] = $investor;    
                    }
                    ?>
                        <td class="alt3"><?php echo $foreign[0]['name'] ?></td>
                        <td class="alt2"><?php echo $foreign[0]['sell'] ?></td>
                        <td class="alt2"><?php echo $foreign[0]['buy'] ?></td>
                        
                        <td class="alt3"><?php echo $inside[0]['name'] ?></td>
                        <td class="alt2"><?php echo $inside[0]['sell'] ?></td>
                        <td class="alt2"><?php echo $inside[0]['buy'] ?></td>
                    </tr>
                    <tr>
                        <td class="alt3"><?php echo $foreign[1]['name'] ?></td>
                        <td class="alt2"><?php echo $foreign[1]['sell'] ?></td>
                        <td class="alt2"><?php echo $foreign[1]['buy'] ?></td>
                        
                        <td class="alt3"><?php echo $inside[1]['name'] ?></td>
                        <td class="alt2"><?php echo $inside[1]['sell'] ?></td>
                        <td class="alt2"><?php echo $inside[1]['buy'] ?></td>
                    </tr>
                
                </table>
                </div>
                <!-- nha dau tu -->
                <br/>
                <!-- bao cao phan tich -->
                <div id="indextbl">BÁO CÁO PHÂN TÍCH</div>  
                <div id="indexcontent" style="background-color: #FFFFFF;" class="halfmoon">                    
                    <?php
                        foreach($analyze_reports as $report)
                        {
                    ?>
                        <p>&raquo; <a href="<?php echo base_url(); ?>uploads/company/report/<?php echo $report['upload'] ?>" target="blank" class="normalNews"><?php echo $report['title'] ?></a></p>            
                    <?php
                        }
                    ?>
                </div>
                <!-- bao cao phan tich -->
            </div></td>
                </tr>
            </table>
        </div>
        <div class="clear" style="height: 2px; background-color: #FFFFFF; width: 987;"></div>
<?php
    echo Modules::run('ndh/footer');
?>